package chat;

import java.util.ArrayList;
import java.util.List;

public class PlayerList {

	private List<Player> playerList;
	
	public PlayerList()
	{
		this.playerList = new ArrayList<Player>();
		
	}
	
	public void addPlayer(Player playerObj)
	{
		this.playerList.add(playerObj);
	}
	
	public void removePlayer(Player playerObj)
	{
		for(Player player : this.playerList)
		{
			if(player.getName() == playerObj.getName())
			{
				this.playerList.remove(player);
			}
		}
	}
	
	public Player getPlayer(String username)
	{
		for(Player player : this.playerList)
		{
			if(player.getName() == username)
			{
				return player;
			}
		}
		return null;
	}
	
	public List<Player> getList()
	{
		return this.playerList;
	}
	
}
